# -*- coding: utf-8 -*-
from datetime import timedelta
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator
# from jms.dm.dm_center_arrival_nonstop_detail_dt import jms_dws__dws_center_arrival_nonstop_sum_dt
from jms_dm_ide.dm.dm_center_arrival_nonstop_detail_dt import jms_dm__dm_center_arrival_nonstop_detail_dt




jms_dws__dws_center_arrival_nonstop_sum_dt = SparkSqlOperator(
    task_id='jms_dws__dws_center_arrival_nonstop_sum_dt',
    task_concurrency=1,
    pool_slots=1,
    master='yarn',
    execution_timeout=timedelta(hours=1),
    email=['yushuo@jtexpress.com','yl_bigdata@yl-scm.com'],
    name='jms_dws__dws_center_arrival_nonstop_sum_dt_{{ execution_date | date_add(1) | cst_ds }}',
    sql='jms_dm_ide/dws/dws_center_arrival_nonstop_sum_dt/execute.sql',
    driver_memory='2G' , 
    driver_cores=2 , 
    executor_cores=2 , 
    executor_memory='1G' , 
    num_executors=2 , 
    conf={
        'spark.dynamicAllocation.enabled': 'true',  # 动态资源开启
        'spark.shuffle.service.enabled': 'true',  # 动态资源 Shuffle 服务开启
        'spark.dynamicAllocation.maxExecutors'             : 2 , 
        'spark.dynamicAllocation.cachedExecutorIdleTimeout': 60,  # 动态资源自动释放闲置 Executor 的超时时间(s)
        'spark.sql.sources.partitionOverwriteMode': 'dynamic',  # 允许删改已存在的分区
        'spark.executor.memoryOverhead'             : '1G' , 
        'spark.sql.shuffle.partitions': 100,
    },
    hiveconf={
        'hive.exec.dynamic.partition': 'true',  # 动态分区
        'hive.exec.dynamic.partition.mode': 'nonstrict',
        'hive.exec.max.dynamic.partitions': 20,  # 每天生成 20 个分区
        'hive.exec.max.dynamic.partitions.pernode': 20  # 每天生成 20 个分区
    },
)
jms_dws__dws_center_arrival_nonstop_sum_dt << jms_dm__dm_center_arrival_nonstop_detail_dt
